/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Lista4_Num2;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.util.Iterator;
import managementcollaborators.Collaborator;
import padraoIterator.Clientes;
import padraoIterator.Colaboradores;
import sistemaa.Cliente;

/**
 *
 * @author Kdc
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        try {
            System.out.println("Gerando Relatório . . .\n\n");

            File f = new File("src/relatorio/relatorio.txt");
            FileWriter fw = new FileWriter(f, true);
            PrintWriter pw = new PrintWriter(fw);

            Clientes cl = new Clientes();
            Colaboradores cb = new Colaboradores();

            Iterator i = cl.creatIterator();
            Iterator it = cb.creatIterator();

            String linha;

            while (i.hasNext()) {
                Cliente c1 = (Cliente) i.next();
                linha = c1.getNomeCompleto() + "," + c1.getTelefone() + "," + c1.getEmail();
                pw.println(linha);

            }

            while (it.hasNext()) {
                Collaborator c1 = (Collaborator) it.next();
                linha = c1.getFirstName() + " " + c1.getMiddleName() + " " + c1.getLastName()
                        + "," + c1.getPhone() + "," + c1.getEmail();
                pw.println(linha);
            }

            pw.close();

            System.out.println("Relatório Gerado com Sucesso!\n\n");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}
